<?php
declare(strict_types=1);
namespace Field;

class StoreProductConst
{
    public const pk='ProductID';
    public const index=['ProductID'];
	public const fields=['ProductID','CateID','Title','Pinyin','Brief','AttachID','VideoAttachID','Price','OriginalPrice','Rank','Status','IsDelete','UpdateAt','CreateAt','AttachIDArr','LastVer'];
	public const comment=['ProductID'=>'商品id','CateID'=>'商品分类','Title'=>'商品名称','Pinyin'=>'拼音用来伪静态路径','Brief'=>'商品简介','AttachID'=>'主图ID','VideoAttachID'=>'主视频ID','Price'=>'商品价格','OriginalPrice'=>'','Rank'=>'排序','Status'=>'状态 1启用 2售罄','IsDelete'=>'是否删除','UpdateAt'=>'','CreateAt'=>'添加时间','AttachIDArr'=>'主图轮播ID','LastVer'=>'最后版本'];
	/*
    * @Field ProductID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 商品id
    */
    public const ProductID = 'ProductID';
    /*
    * @Field CateID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 商品分类
    */
    public const CateID = 'CateID';
    /*
    * @Field Title
    * @Type char(64)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 商品名称
    */
    public const Title = 'Title';
    /*
    * @Field Pinyin
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 拼音用来伪静态路径
    */
    public const Pinyin = 'Pinyin';
    /*
    * @Field Brief
    * @Type varchar(200)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 商品简介
    */
    public const Brief = 'Brief';
    /*
    * @Field AttachID
    * @Type int(10)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 主图ID
    */
    public const AttachID = 'AttachID';
    /*
    * @Field VideoAttachID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 主视频ID
    */
    public const VideoAttachID = 'VideoAttachID';
    /*
    * @Field Price
    * @Type int(11) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 商品价格
    */
    public const Price = 'Price';
    /*
    * @Field OriginalPrice
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const OriginalPrice = 'OriginalPrice';
    /*
    * @Field Rank
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 9999
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 排序
    */
    public const Rank = 'Rank';
    /*
    * @Field Status
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 状态 1启用 2售罄
    */
    public const Status = 'Status';
    /*
    * @Field IsDelete
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 是否删除
    */
    public const IsDelete = 'IsDelete';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const UpdateAt = 'UpdateAt';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 添加时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field AttachIDArr
    * @Type varchar(600)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 主图轮播ID
    */
    public const AttachIDArr = 'AttachIDArr';
    /*
    * @Field LastVer
    * @Type varchar(16)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 最后版本
    */
    public const LastVer = 'LastVer';
}

class StoreProductColumns
{
public  int $ProductID;
   public  int $CateID=0;
   public  string $Title;
   public  ?string $Pinyin='';
   public  ?string $Brief='';
   public  int $AttachID=0;
   public  int $VideoAttachID=0;
   public  int $Price=0;
   public  int $OriginalPrice=0;
   public  int $Rank=0;
   public  int $Status=0;
   public  int $IsDelete=0;
   public  ?string $UpdateAt='';
   public  ?string $CreateAt='';
   public  ?string $AttachIDArr='';
   public  ?string $LastVer='';
	public function toArray():array
	{
		return [
'ProductID'=>$this->ProductID,
    'CateID'=>$this->CateID,
    'Title'=>$this->Title,
    'Pinyin'=>$this->Pinyin,
    'Brief'=>$this->Brief,
    'AttachID'=>$this->AttachID,
    'VideoAttachID'=>$this->VideoAttachID,
    'Price'=>$this->Price,
    'OriginalPrice'=>$this->OriginalPrice,
    'Rank'=>$this->Rank,
    'Status'=>$this->Status,
    'IsDelete'=>$this->IsDelete,
    'UpdateAt'=>$this->UpdateAt,
    'CreateAt'=>$this->CreateAt,
    'AttachIDArr'=>$this->AttachIDArr,
    'LastVer'=>$this->LastVer,        ];
	}
}

class StoreProductRow
{
	public StoreProductColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'ProductID' => $this->data->ProductID,
        'CateID' => $this->data->CateID,
        'Title' => $this->data->Title,
        'Pinyin' => $this->data->Pinyin,
        'Brief' => $this->data->Brief,
        'AttachID' => $this->data->AttachID,
        'VideoAttachID' => $this->data->VideoAttachID,
        'Price' => $this->data->Price,
        'OriginalPrice' => $this->data->OriginalPrice,
        'Rank' => $this->data->Rank,
        'Status' => $this->data->Status,
        'IsDelete' => $this->data->IsDelete,
        'UpdateAt' => $this->data->UpdateAt,
        'CreateAt' => $this->data->CreateAt,
        'AttachIDArr' => $this->data->AttachIDArr,
        'LastVer' => $this->data->LastVer, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new StoreProductColumns();
        isset($data['ProductID']) && $this->data->ProductID = (int)$data['ProductID'];
           isset($data['CateID']) && $this->data->CateID = (int)$data['CateID'];
           isset($data['Title']) && $this->data->Title = (string)$data['Title'];
           isset($data['Pinyin']) && $this->data->Pinyin = (string)$data['Pinyin'];
           isset($data['Brief']) && $this->data->Brief = (string)$data['Brief'];
           isset($data['AttachID']) && $this->data->AttachID = (int)$data['AttachID'];
           isset($data['VideoAttachID']) && $this->data->VideoAttachID = (int)$data['VideoAttachID'];
           isset($data['Price']) && $this->data->Price = (int)$data['Price'];
           isset($data['OriginalPrice']) && $this->data->OriginalPrice = (int)$data['OriginalPrice'];
           isset($data['Rank']) && $this->data->Rank = (int)$data['Rank'];
           isset($data['Status']) && $this->data->Status = (int)$data['Status'];
           isset($data['IsDelete']) && $this->data->IsDelete = (int)$data['IsDelete'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['AttachIDArr']) && $this->data->AttachIDArr = (string)$data['AttachIDArr'];
           isset($data['LastVer']) && $this->data->LastVer = (string)$data['LastVer'];
    }
}
?>